package com.cedric.yixianpai.game.cards.Sects.swordCards.e_HuaShen;

import com.cedric.yixianpai.game.Constants.CardType;
import com.cedric.yixianpai.game.Constants.Period;
import com.cedric.yixianpai.game.Status.DuelStatus;
import com.cedric.yixianpai.game.interfaces.SwordCard;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Yun_YouLong extends SwordCard {
    private final int count;

    /**
     * title:云剑·游龙
     * effect:2x2/3/4攻 连云：防+3/5/7 击伤：再动
     */
    public Yun_YouLong(@Value("1") int lvl) {
        super("云剑·游龙");
        this.setLevel(lvl);
        this.setPeriod(Period.HUASHEN);
        this.setDescription("2攻x2/3/4 连云：防+3/5/7 击伤：再动");
        this.setCardType(CardType.YUN);
        this.setDamage(2);
        if (1 == lvl) {
            this.count = 2;
            this.setShield(3);
        } else if (2 == lvl) {
            this.count = 3;
            this.setShield(5);
        } else if (3 == lvl) {
            this.count = 4;
            this.setShield(7);
        } else {
            throw new RuntimeException("Card Level Error!");
        }
    }

    @Override
    public boolean effect(DuelStatus Sta1, DuelStatus Sta2) {
        for (int i = 0; i < this.count; i++) {
            if (Sta1.attack(Sta2, this.getDamage()) > 0) {
                Sta1.setAgain();
            }
        }
        Sta1.getPlayerBuff().clearSwordIntent();
        if (Sta1.lastIs(CardType.YUN)) {
            Sta1.getPlayerBuff().addShield(this.getShield());
        }
        return true;
    }
}
